import { wxRequest } from '../../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: app.globalData.imgUrl,
    uploadUrl: wx.getStorageSync('uploadUrl'),
    hideDetail:false,
    detail:{},
    typefg:'',
    type:''
  },
  
  onLoad: function (options) {  
    if (options.id) {
      this.setData({
        id: options.id,
        typefg: options.typefg||'',
        type: options.type || ''
      })
    }
  },

  onShow:function(){
    this.getdetail()
  },

  //显示隐藏
  detailState:function(){
    this.setData({
      hideDetail: !this.data.hideDetail
    })
  },

  //复制订单号
  copy: function (e){
    var that = this;
    var text = e.currentTarget.dataset.text
    wx.setClipboardData({
      //去找上面的数据
      data: text,
      success: function (res) {
        wx.showToast({
          title: '复制成功',
        });
      }
    }); 
  },


  //获取详情
  getdetail: function () { 
    var url = '/odr/protected/order/detail?id=' + this.data.id
    // if(this.data.type==2){
    //   url = '/odr/protected/orgOrder/detail?id=' + this.data.id
    // } 
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + url,
      method: 'POST',
    }, (res) => {
      var resVo = res.vo
      if (typeof resVo.detailJson == 'string') {
        resVo.detailJson = JSON.parse(resVo.detailJson)
      }
      console.log(resVo, 'resVo')
      this.setData({
        detail: resVo
      })
    })
  },

  clickCopy(e) {
      const copyContent = e.currentTarget.dataset.content;
      wx.setClipboardData({
        data: copyContent,
        success: (res) => {
          wx.showToast({
            icon: "success",
            title: '复制成功',
          })
        }
      });

  },


  //去发货
  toDelives:function(e){
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url:'/pages/menber/mall/deliver?id='+id
    }) 
   
  }
})